package com.my.order.service.impl.stub;

import com.my.common.domain.UserAddress;
import com.my.common.service.UserService;
import org.springframework.stereotype.Service;

import java.util.List;

//UserService远程接口的本地存根，可在此对远程接口代理对象进行封装、参数校验等操作
@Service
public class UserServiceStub implements UserService {

    private final UserService userService;

    //必须提供有参构造，封装远程接口代理对象
    public UserServiceStub(UserService userService){
        this.userService = userService;
    }


    @Override
    public List<UserAddress> getList(Integer id) {
        System.out.println("本地存根-参数校验...");
        if(id == null || id <= 0){
            return null;//模拟参数校验
        }
        return userService.getList(id);//调用远程接口
    }
}
